import { View, Text,Image } from '@tarojs/components'
import { useState,useEffect } from 'react'
import Taro from '@tarojs/taro'
import { AtList, AtListItem,AtTabBar,AtIcon } from "taro-ui"
import './my.less'
import store from '../../store/index.js'
import img from '../../img/tabbarIcon/2.png'

const My=()=>{
    useEffect(() => {
        setusername(JSON.parse(JSON.stringify(store.userData)));
    }, [])
    setTimeout(()=>{
        setusername(JSON.parse(JSON.stringify(store.userData)));
    },1000)
    const [current,setCurrent]=useState(0)
    const handleClick=(ev)=>{
        console.log(ev);
        setCurrent(ev)
    }
    const footprint=(ev)=>{
        Taro.navigateTo({
            url:'/pages/footprint/footprint'
        })
    }
    const address=()=>{
        Taro.navigateTo({
            url:'/pages/address/address'
        })
    }
    const sale=()=>{
        Taro.navigateTo({
            url:'/pages/my/myalter/myalter'
        })
    }
    const myOuder=()=>{
      Taro.navigateTo({
        url:'/pages/my/myOrder/myOrder'
      })
    }

    const [userName,setusername]=useState({})
    const aa=()=>{
        console.log(JSON.parse(JSON.stringify(store.userInformation)),store.sid);
    }
        return (
            <View>
                <Text className='myTit'>我的</Text>
                <View className='info'>
                    <View className='infoBox'>
                        <View className='imginfo'>
                            <Image src={userName.avatarUrl} onClick={aa}></Image>
                        </View>
                        <View style={{width:'150px'}}>
                            <Text style={{fontWeight:'bold',fontSize:'28px'}}>{userName.nickName}</Text>
                            <View style={{fontSize:'14px'}}>购物愉快~</View>
                        </View>
                    </View>
                </View>
                <View className='order'>
                    <View className='orderInfo'>
                        <View>

                            <View>商品订单</View>
                        </View>
                        <View className='orderInfoRight'>
                            <View onClick={myOuder}>查看订单</View>
                            <AtIcon value='chevron-right' size='20'></AtIcon>
                        </View>
                    </View>
                    <View className='orderList'>
                        <View className='orderFl'>
                            <AtIcon value='credit-card' size='30' color='rgb(51,51,51)' className='orderImg'></AtIcon>
                            <Text>待收款</Text>
                        </View>
                        <View className='orderFl'>
                            <AtIcon value='shopping-cart' size='30' color='rgb(51,51,51)' className='orderImg' ></AtIcon>
                            <Text>待发货</Text>
                        </View>
                        <View className='orderFl'>
                            <AtIcon value='tags' size='30' color='rgb(51,51,51)' className='orderImg'></AtIcon>
                            <Text>待完成</Text>
                        </View>
                        <View className='orderFl'>
                            <AtIcon value='check-circle' color='rgb(51,51,51)' size='30'  className='orderImg'></AtIcon>
                            <Text>已完成</Text>
                        </View>
                    </View>
                </View>
                <View className='infoList'>
                    <AtList>
                        <AtListItem title='我的足迹' arrow='right' onClick={footprint} />
                        <AtListItem title='我的地址' arrow='right' onClick={address}/>
                        <AtListItem title='我的售后' arrow='right' onClick={sale}/>
                        <AtListItem title='联系客服' arrow='right' />
                    </AtList>
                </View>
            </View>
        )
}
export default My;
